package com.sec.etech.bpm.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.apache.ibatis.plugin.Interceptor;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.openbpm.base.autoconfiguration.DataSourceAutoConfiguration;
import org.openbpm.base.autoconfiguration.DataSourceExtraProperties;
import org.openbpm.base.dao.baseinterceptor.QueryInterceptor;
import org.openbpm.base.dao.baseinterceptor.SaveInterceptor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import javax.sql.DataSource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

/**
 * 数据源配置
 *
 */
@Primary
@Configuration
public class DataSourceConfiguration {

 // DAO 层 BasePackage TODO 可配置
    @Bean("bpmMapperScannerConfigurer2")
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        mapperScannerConfigurer.setSqlSessionFactoryBeanName("bpmSqlSessionFactory");
        mapperScannerConfigurer.setBasePackage("com.sec.etech.**.dao,com.sec.etech.**.mapper,**.mapper,org.openbpm.**.dao,org.openbpm.**.mapper,**.mapper");
        return mapperScannerConfigurer;
    }

}
